package de.lmu.ifi.pst.uwejsf.framework.process;

import org.apache.commons.beanutils.BeanUtils;

public abstract class UserAction extends Action {

	public UserAction(ProcessActivityBean activity) {
		super(activity);

	}

	public abstract ProcessClassBean getProcessClassBean();

	public abstract void storeSubmittedValues();

	@Override
	public void populateInputValues(Object bean) {
		try {
			BeanUtils.copyProperties(getProcessClassBean(), bean);
		} catch (Exception e) {
			throw new ProcessDataflowException(
					"Error populating properties on "
							+ getProcessClassBean().getClass().getName()
							+ " using " + bean.getClass().getName(), e);
		}
	}

	@Override
	public void setInputValue(String name, Object value) {

		try {
			BeanUtils.copyProperty(getProcessClassBean(), name, value);
		} catch (Exception e) {
			throw new ProcessDataflowException(
					"Error setting property " + name + " on "
							+ getProcessClassBean().getClass().getName() + ".",
					e);
		}

	}
}
